package com.iot.controller;


import com.iot.dto.CommandRequestDTO;
import com.iot.relay.ExchangeData;
import com.iot.service.DeviceCommandService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "执行下发")
@RequestMapping("/command")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CommandController {

    private final DeviceCommandService deviceCommandService;

    @PutMapping("/send")
    @ApiOperation(value = "执行下发消息", notes = "执行下发消息")
    public ExchangeData<Boolean> sendCommand(CommandRequestDTO dto) {
        deviceCommandService.sendCommand(dto);
        ExchangeData<Boolean> exchangeData = new ExchangeData<>();
        exchangeData.setMessage("指令已发送");
        return exchangeData;
    }
}
